<f:view xmlns="http://www.w3.org/1999/xhtml" 
	xmlns:aui="http://liferay.com/faces/aui"
	xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" 
	xmlns:bridge="http://liferay.com/faces/bridge"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:example-cc="http://java.sun.com/jsf/composite/example-cc"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<f:event listener="#{weekReportController.loadData}" type="preRenderView" />
	
	<h:form id="weekReportForm" styleClass="weekReportForm" >
		<h:panelGroup styleClass="weekReportTitle contentTitle" >
			<h:outputText value="Kalenderwoche: #{weekReportController.calendarWeek}" 
						styleClass="weekReportTitleValue contentTitleValue" />
			<h:outputText value="Datum von: #{weekReportController.weekReportDateMondayString} bis: #{weekReportController.weekReportDateSundayString}" 
						styleClass="weekReportTitleValue contentTitleValue" />
			<p:commandButton value="" 
						title="Zeige vorherige Woche" 
						styleClass="weekReportButton weekReportNavButton fontello-left-open" 
						actionListener="#{weekReportController.navigateWeekBackward}" 
						ajax="false" />
			<p:commandButton value="" 
						title="Zeige nächste Woche" 
						styleClass="weekReportButton weekReportNavButton fontello-right-open" 
						actionListener="#{weekReportController.navigateWeekForward}" 
						ajax="false" />
			<p:commandButton value="Speichern" 
						title="Speichern" 
						styleClass="weekReportButton" 
						actionListener="#{weekReportController.saveWeekReport}" 
						ajax="false" />
			<p:commandButton value="Abschliessen" 
						title="Wochenrapport abschliessen" 
						styleClass="weekReportButton" 
						actionListener="#{weekReportController.closeWeekReport}" 
						ajax="false" />
		</h:panelGroup>
	    <p:dataTable var="reportEntry" value="#{weekReportController.prodWeekReportEntries}" 
	    			 sortBy="#{reportEntry.workingIdentifier.name}" styleClass="prodHours" >
	        <p:column headerText="Projektnummer" styleClass="projectNumber" >
	            <h:outputText value="#{reportEntry.appointment.projectNumber}" />
	        </p:column>
	         
	        <p:column headerText="Auftrag" styleClass="appointment" >
	            <h:outputText value="#{reportEntry.appointment.subject}" />
	        </p:column>
	        
	        <p:column headerText="Art" sortBy="#{reportEntry.workingIdentifier.subentity}" styleClass="prodHoursKind" >
	            <h:outputText value="#{reportEntry.workingIdentifier.subentity}" />
	        </p:column>
	        
	        <p:column headerText="Mo" styleClass="timefield workday monday" >
	            <h:outputText value="#{reportEntry.monday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Di" styleClass="timefield workday tuesday" >  
	            <h:outputText value="#{reportEntry.tuesday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Mi" styleClass="timefield workday wednesday" >  
	            <h:outputText value="#{reportEntry.wednesday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Do" styleClass="timefield workday thursday" >  
	            <h:outputText value="#{reportEntry.thursday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Fr" styleClass="timefield workday friday" >  
	            <h:outputText value="#{reportEntry.friday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Sa" styleClass="timefield weekendDay saturday" >  
	            <h:outputText value="#{reportEntry.saturday.hours}" />
	        </p:column>
	        
	        <p:column headerText="So" styleClass="timefield weekendDay sunday" >  
	            <h:outputText value="#{reportEntry.sunday.hours}" />
	        </p:column>
	        
	        <p:column headerText="Total" styleClass="timefield total" >
	            <h:outputText value="#{reportEntry.total}" />
	        </p:column>
	        
	        <p:columnGroup type="footer">  
                <p:row>  
                    <p:column footerText="Total produktive Stunden" colspan="2" style="text-align:right"/>  
                    <p:column footerText="#{weekReportController.totalProdMonday}" />  
                    <p:column footerText="#{weekReportController.totalProdTuesday}" />
                    <p:column footerText="#{weekReportController.totalProdWednesday}" />
                    <p:column footerText="#{weekReportController.totalProdThursday}" />
                    <p:column footerText="#{weekReportController.totalProdFriday}" />
                    <p:column footerText="#{weekReportController.totalProdSaturday}" />
                    <p:column footerText="#{weekReportController.totalProdSunday}" />
                    <p:column footerText="#{weekReportController.totalProdTotal}" />
                </p:row>
            </p:columnGroup>
	    </p:dataTable>
	    <p:dataTable var="reportEntry" value="#{weekReportController.unprodWeekReportEntries}" 
	    			 styleClass="unprodHours" >
	        <p:column>
	            <h:outputText value="#{reportEntry.workingIdentifier.name}" />
	        </p:column>
	        
	        <p:column styleClass="timefield workday monday" >
	            <h:inputText value="#{reportEntry.monday.hours}" 
	            		styleClass="weekReportTextField"
	            		maxlength="4" >
	            	<f:validateDoubleRange maximum="8" />
	            </h:inputText>
	        </p:column>
	        
	        <p:column styleClass="timefield workday tuesday" >  
	            <h:inputText value="#{reportEntry.tuesday.hours}" 
	            		styleClass="weekReportTextField"
	            		maxlength="4" >
	            	<f:validateDoubleRange maximum="8" />
	            </h:inputText>
	        </p:column>
	        
	        <p:column styleClass="timefield workday wednesday" >
	            <h:inputText value="#{reportEntry.wednesday.hours}" 
	            		styleClass="weekReportTextField"
	            		maxlength="4" >
	            	<f:validateDoubleRange maximum="8" />
	            </h:inputText>
	        </p:column>
	        
	        <p:column styleClass="timefield workday thursday" >
	            <h:inputText value="#{reportEntry.thursday.hours}" 
	            		styleClass="weekReportTextField"
	            		maxlength="4" >
	            	<f:validateDoubleRange maximum="8" />
	            </h:inputText>
	        </p:column>
	        
	        <p:column styleClass="timefield workday friday" >
	            <h:inputText value="#{reportEntry.friday.hours}" 
	            		styleClass="weekReportTextField"
	            		maxlength="4" >
	            	<f:validateDoubleRange maximum="8" />
	            </h:inputText>
	        </p:column>
	        
	        <p:column styleClass="timefield weekendDay saturday" > 
	            <h:outputText value="" />
	        </p:column>
	        
	        <p:column styleClass="timefield weekendDay sunday" >
	            <h:outputText value="" />
	        </p:column>
	        
	        <p:column styleClass="timefield total" >
	            <h:outputText value="#{reportEntry.total}" />
	        </p:column>
	        
	        <p:columnGroup id="columnGroupTotal" type="footer">  
                <p:row>  
                    <p:column footerText="Total unproduktive Stunden" style="text-align:right"/>  
                    <p:column footerText="#{weekReportController.totalUnprodMonday}" />  
                    <p:column footerText="#{weekReportController.totalUnprodTuesday}" />
                    <p:column footerText="#{weekReportController.totalUnprodWednesday}" />
                    <p:column footerText="#{weekReportController.totalUnprodThursday}" />
                    <p:column footerText="#{weekReportController.totalUnprodFriday}" />
                    <p:column footerText="#{weekReportController.totalUnprodSaturday}" />
                    <p:column footerText="#{weekReportController.totalUnprodSunday}" />
                    <p:column footerText="#{weekReportController.totalUnprodTotal}" />
                </p:row>
                <p:row>  
                    <p:column footerText="Total IST-Stunden" style="text-align:right"/>
                    <p:column footerText="#{weekReportController.totalMonday}" 
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalMonday ge 8 and weekReportController.totalMonday le 15}" />
                    <p:column footerText="#{weekReportController.totalMonday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalMonday lt 8 or weekReportController.totalMonday > 15}" />  
                    <p:column footerText="#{weekReportController.totalTuesday}"
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalTuesday ge 8 and weekReportController.totalTuesday le 15}" />
                    <p:column footerText="#{weekReportController.totalTuesday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalTuesday lt 8 or weekReportController.totalTuesday > 15}" />
                    <p:column footerText="#{weekReportController.totalWednesday}"
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalWednesday ge 8 and weekReportController.totalWednesday le 15}" />
                    <p:column footerText="#{weekReportController.totalWednesday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalWednesday lt 8 or weekReportController.totalWednesday > 15}" />		
                    <p:column footerText="#{weekReportController.totalThursday}"
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalThursday ge 8 and weekReportController.totalThursday le 15}" />
                    <p:column footerText="#{weekReportController.totalThursday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalFriday lt 8 or weekReportController.totalFriday > 15}" />
                    <p:column footerText="#{weekReportController.totalFriday}"
                     		styleClass="weekReportTotal"
                     		rendered="#{weekReportController.totalFriday ge 8 and weekReportController.totalFriday le 15}" />
                    <p:column footerText="#{weekReportController.totalFriday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalFriday lt 8 or weekReportController.totalFriday > 15}" />
                    <p:column footerText="#{weekReportController.totalSaturday}"
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalSaturday ge 8 and weekReportController.totalSaturday le 15}" />
                    <p:column footerText="#{weekReportController.totalSaturday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalSaturday lt 8 or weekReportController.totalSaturday > 15}" />
                    <p:column footerText="#{weekReportController.totalSunday}"
                    		styleClass="weekReportTotal"
                    		rendered="#{weekReportController.totalSunday ge 8 and weekReportController.totalSunday le 15}" />
                    <p:column footerText="#{weekReportController.totalSunday}" 
                    		styleClass="weekReportTotal weekReportTotalError" 
                    		rendered="#{weekReportController.totalSunday lt 8 or weekReportController.totalSunday > 15}" />
                    <p:column footerText="#{weekReportController.totalTotal}"
                    		styleClass="weekReportTotal" />
                </p:row>
                <p:row>  
                    <p:column footerText="Total SOLL-Stunden" style="text-align:right"/>  
                    <p:column footerText="8.0" />  
                    <p:column footerText="8.0" />
                    <p:column footerText="8.0" />
                    <p:column footerText="8.0" />
                    <p:column footerText="8.0" />
                    <p:column footerText="0.0" />
                    <p:column footerText="0.0" />
                    <p:column footerText="40.0" />
                </p:row>
                <p:row>  
                    <p:column footerText="Kompensationsguthaben" style="text-align:right"/>  
                    <p:column footerText="#{weekReportController.compensationMonday}" />  
                    <p:column footerText="#{weekReportController.compensationTuesday}" />
                    <p:column footerText="#{weekReportController.compensationWednesday}" />
                    <p:column footerText="#{weekReportController.compensationThursday}" />
                    <p:column footerText="#{weekReportController.compensationFriday}" />
                    <p:column footerText="#{weekReportController.compensationSaturday}" />
                    <p:column footerText="#{weekReportController.compensationSunday}" />
                    <p:column footerText="#{weekReportController.compensationTotal}" />
                </p:row>
            </p:columnGroup>
	    </p:dataTable>
	</h:form>
</f:view>